/*
 * UserRepository.java
 * Copyright (c) 2014, 2019, Kiri. 
 * All rights reserved.
 */
package com.onesalt.service;

import java.util.List;

import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.onesalt.domain.User;

/**
 * UserRepository
 *
 * @author kiri
 * @date 2015年3月22日
 * @version 1.0
 */
public interface UserRepository extends PagingAndSortingRepository<User, Long>, JpaSpecificationExecutor<User> {

	@Query("select u.city from t_user u group by u.city")
	public List<String> findAllCities();
	
	public User findBySn(String sn);
	
	public User findByMobile(String mobile);
	
	@Modifying
	@Query("delete from t_user u where u.sn = ?1")
	public int deleteBySn(String sn);
	
	public User findTopByCookAuditStatus(String cookAuditStatus, Sort sort);
}
